Skip to content

Add RealTek AmebaPro2 (RTL8735B) HUK wolfCrypt example#575

Open
dgarske wants to merge 1 commit into
wolfSSL:masterfrom
dgarske:amebapro2-huk-example
Open

Add RealTek AmebaPro2 (RTL8735B) HUK wolfCrypt example#575
dgarske wants to merge 1 commit into
wolfSSL:masterfrom
dgarske:amebapro2-huk-example

Conversation

@dgarske

@dgarske dgarske commented Jun 12, 2026

Copy link
Copy Markdown
Member

@dgarske dgarske self-assigned this Jun 12, 2026
Copilot AI review requested due to automatic review settings June 12, 2026 23:40

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new RealTek AmebaPro2 (RTL8735B) wolfCrypt example that demonstrates using the Hardware Unique Key (HUK) via wolfCrypt CryptoCb, intended to be built inside the RealTek FreeRTOS SDK.

Changes:

  • Introduces an AmebaPro2 HUK AES example app (GCM/ECB/CBC/CTR) that registers the HUK crypto-callback device and runs known-answer/round-trip checks.
  • Adds a minimal user_settings.h configuration for a wolfCrypt-only, AES-focused build in the SDK.
  • Adds CMake wiring (wolfcrypt_huk.cmake) and README instructions for integrating the example into the RealTek SDK build.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 8 comments.

File Description
AmebaPro2/main.c New FreeRTOS task example exercising AES modes via the HUK crypto-callback device.
AmebaPro2/user_settings.h New wolfCrypt configuration for the example (CryptoCb + AES modes + HashDRBG seed hook).
AmebaPro2/wolfcrypt_huk.cmake New SDK build “wiring” to add wolfCrypt sources, include paths, and defines.
AmebaPro2/README.md New integration/build/flash documentation for the AmebaPro2 HUK example.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread AmebaPro2/main.c
Comment on lines +87 to +91
seed[0] ^= 0xFF;
wc_AesGcmSetKey(&aes, seed, sizeof(seed));
ret = wc_AesGcmDecrypt(&aes, dec, ct, sizeof(ct), iv, sizeof(iv),
tag, sizeof(tag), aad, sizeof(aad));
CHECK("wrong seed -> AES_GCM_AUTH_E", ret == AES_GCM_AUTH_E);
Comment thread AmebaPro2/main.c
Comment on lines +108 to +111
dbg_printf("\r\n== AES-ECB under HUK-derived key ==\r\n");
wc_AesInit(&aes, NULL, WC_HUK_DEVID);
ret = wc_AesSetKey(&aes, seed, sizeof(seed), NULL, AES_ENCRYPTION);
CHECK("AesSetKey(ECB enc)", ret == 0);
Comment thread AmebaPro2/main.c
Comment on lines +119 to +122
dbg_printf("\r\n== AES-CBC under HUK-derived key ==\r\n");
wc_AesInit(&aes, NULL, WC_HUK_DEVID);
ret = wc_AesSetKey(&aes, seed, sizeof(seed), iv, AES_ENCRYPTION);
CHECK("AesSetKey(CBC enc)", ret == 0);
Comment thread AmebaPro2/main.c
Comment on lines +144 to +147
dbg_printf("\r\n== AES-CTR under HUK-derived key ==\r\n");
wc_AesInit(&aes, NULL, WC_HUK_DEVID);
ret = wc_AesSetKeyDirect(&aes, seed, sizeof(seed), iv, AES_ENCRYPTION);
CHECK("AesSetKeyDirect(CTR)", ret == 0);
Comment thread AmebaPro2/main.c
Comment on lines +153 to +156
/* CTR is its own inverse with the same key+IV */
wc_AesInit(&aes, NULL, WC_HUK_DEVID);
wc_AesSetKeyDirect(&aes, seed, sizeof(seed), iv, AES_ENCRYPTION);
ret = wc_AesCtrEncrypt(&aes, dec, ct, sizeof(ct));
Comment thread AmebaPro2/main.c
Comment on lines +179 to +182
dbg_printf("\r\n== AES-GCM with UNALIGNED buffers (port bounces) ==\r\n");
wc_AesInit(&aes, NULL, WC_HUK_DEVID);
ret = wc_AesGcmSetKey(&aes, seed, 32);
CHECK("AesGcmSetKey (unaligned seed)", ret == 0);
Comment thread AmebaPro2/README.md
## Prerequisites

- RealTek AmebaPro2 FreeRTOS SDK: https://github.com/Ameba-AIoT/ameba-rtos-pro2
- RealTek ASDK 10.3.0 toolchain (GCC 10.3.0): https://github.com/Ameba-AIoT/ameba-toolchain (tag `V10.3.0-amebe-rtos-pro2`). The stock system `arm-none-eabi-gcc` does not build the SDK (newlib/lwip header clashes); use the ASDK toolchain.
set(WOLFSSL_ROOT ${CMAKE_CURRENT_LIST_DIR}/../../../../wolfssl)
endif()
endif()
if(NOT EXISTS ${WOLFSSL_ROOT}/wolfcrypt/src/aes.c)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants